<template>
  <div  style="padding: 10px">
    <h2 style="margin-bottom: 10px;">菜单帮助系统</h2>
    <div>
      <el-form :model="form" label-width="auto" :inline="true">
        <el-form-item label="查询菜单名称">
          <div >
            <el-input v-model="form.name"  style="width:220px"
          @keydown.native.enter="trigger_getinfoList" size="small"
          clearable
          />
          </div>
        </el-form-item>
        <el-form-item label="菜单路径">
          <el-input v-model="form.funUrl" style="width:220px"  size="small"
                    clearable
          />
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary" size="small"
            @click="
              () => {
                trigger_getinfoList();
              }
            "
            >查询</el-button
          >
        </el-form-item>
      </el-form>
    </div>

    <div>
      <ul>
        <li v-for="funcitem in dataList" style="margin-bottom:10px;">
<span style="margin-right:20px;">{{funcitem.name}}</span>
<span
 style="cursor:pointer;"
@click="()=>{
 createA(`http://dev.szqerp.com${funcitem.fun_url}`)
}">{{funcitem.fun_url}}</span>

</li>
      </ul>
    </div>
  </div>
</template>
<script>
import axios from "axios";
export function createA(href, target) {
  var a = document.createElement('a')
  a.setAttribute('href', href)
  a.setAttribute('target', target || '_blank')
  a.setAttribute('id', 'startTelMedicine')
  // 防止反复添加
  if (document.getElementById('startTelMedicine')) {
    document.body.removeChild(document.getElementById('startTelMedicine'))
  }
  document.body.appendChild(a)
  a.click()
}
export default {
  data() {
    return {
createA,
      form: { name: "", funUrl: "" },
      conf_html: "",
      a: 111,
      dataList: [],
    };
  },
  mounted() {
    this.getconf();
  },
  methods: {
    async trigger_getinfoList() {
      var result = await axios
        .post("/api/routerhelp/list", { ...this.form })
        .then((res) => res.data);
      this.dataList = (result && result.data) || [];
      console.log("result&&result.data||[] :", (result && result.data) || []);
    },
    async getconf() {
      var result = await axios.get("/api/ngnix/conf").then((res) => res.data);
      this.conf_html = result && result.data;
    },
    async triggerRestart(action) {
      axios.get(`/api/exec_ngnix/restart?action=${action}`);
    },
    async triggerstart() {
      axios.get("/api/exec_ngnix/start");
    },
    async triggersaveconf() {
      var self = this;
      debugger;
      axios.post("/api/exec_ngnix/conf_update", {
        content: $(this.$refs["conf_html_ref"]).text(),
      });
    },
  },
};
</script>
